FROM kubespheredev/s2i-base-centos7

ENV TZ=Asia/Shanghai

ENV NODEJS_VERSION=10 \
    NPM_RUN=start \
    NAME=nodejs

ENV SUMMARY="Platform for building and running NodeJS $NODEJS_VERSION applications" \
    DESCRIPTION="NodeJS $NODEJS_VERSION docker container for building and running \
    NodeJS applications."

LABEL summary="$SUMMARY" \
    description="$DESCRIPTION" \
    io.k8s.description="$DESCRIPTION" \
    io.k8s.display-name="NodeJS $NODEJS_VERSION" \
    io.openshift.expose-services="8080:http" \
    io.openshift.tags="builder,$NAME,$NAME$NODEJS_VERSION" \
    io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \
    io.s2i.scripts-url="image:///usr/libexec/s2i"

RUN mkdir -p /opt/node && \
  wget --no-verbose -P /opt/node/ https://nodejs.org/download/release/v10.24.0/node-v10.24.0-linux-x64.tar.gz && \
  tar -xvf /opt/node/node-v10.24.0-linux-x64.tar.gz --directory /opt/node

RUN rm -rf /opt/node/node-v10.24.0-linux-x64.tar.gz 

ENV PATH=/opt/node/node-v10.24.0-linux-x64/bin/:$PATH

# 安装nginx并且清理yum cache
RUN yum install -y epel-release && \
    yum install -y --setopt=tsflags=nodocs nginx && \
    yum clean all

# 将S2I的脚本复制到构建器镜像当中
COPY ./s2i/bin/ /usr/libexec/s2i


# 声明默认使用的端口
EXPOSE 80

# 修改构建器的默认启动命令，以展示构建器镜像的用法
CMD ["/usr/libexec/s2i/usage"]